﻿@page "{id:int?}"
@model CampusNews.Pages.Newwss.IndexModel

@{
    ViewData["Title"] = "Index";
}

<h1>校园新闻</h1>

<p>
    <a asp-page="Create">发布新闻</a>
</p>

<form>
    <p>
        <label>
            类型:
            <select asp-for="NewsGenre" asp-items="Model.Genres">
                <option value="">All</option>
            </select>
        </label>
        <label>关键字: <input type="text" asp-for="SearchString" /></label>
        <input type="submit" value="筛选"/>
    </p>
</form>

<table class="table">
    <thead>
        <tr>
            <th>
                标题 @* @Html.DisplayNameFor(model => model.Newws[0].Title) *@
            </th>
            <th>
                发布时间 @* @Html.DisplayNameFor(model => model.Newws[0].ReleaseDate) *@
            </th>
            <th>
                类型@* @Html.DisplayNameFor(model => model.Newws[0].Genre) *@
            </th>
            @* <th> *@
            @*     @Html.DisplayNameFor(model => model.Newws[0].Price) *@
            @* </th> *@
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model.Newws) {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Title)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ReleaseDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Genre)
                </td>

                <td>
                    
                    @if (!string.IsNullOrEmpty(Model.UserEmail))
                    {

                        <a asp-page="./Details" asp-route-id="@item.Id">新闻详情</a>

                        <a asp-page="./Edit" asp-route-id="@item.Id"> |编辑|</a>

                        @* <a asp-page = "./Edit" asp-route-id = "@item.Id" > 编辑|</ a >  *@
                        <a asp-page="./Delete" asp-route-id="@item.Id">删除</a>


                        @* <a asp-page = "./Delete" asp-route-id = "@item.Id" >删除</ a > *@
                    }

                   
                </td>
        </tr>
}
    </tbody>
</table>
